﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class UserControls_StockKeyfigures : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
      string id = Request.Params["id"];
      StockAnalysis analysis = new StockAnalysis();
      DataTable dt = analysis.GetStockKeyfiguresTable(id);
      gridviewStockKeyfigures.DataSource = ConvertSubFigures.Convert(dt);
      gridviewStockKeyfigures.DataBind();

      Graph g = new Graph();
      Dictionary<string, string[]> graphData = ConvertGraphData.Convert(dt);

      string[] year;
      string[] KI;
      string[] EPS;
      string[] PE;
      string[] PEGRatio;

      graphData.TryGetValue("year", out year);

      graphData.TryGetValue("KI", out KI);
      graphKI.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("KI"), "XAxis", Abbreviations.getAbbreviations("KI"), KI, year, false, false, true);

      graphData.TryGetValue("EPS", out EPS);
      graphEPS.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("EPS"), "XAxis", Abbreviations.getAbbreviations("EPS"), EPS, year, false, false, false);

      graphData.TryGetValue("PE", out PE);
      graphPE.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("PE"), "XAxis", Abbreviations.getAbbreviations("PE"), PE, year, false, false, false);

      graphData.TryGetValue("PEG_ratio", out PEGRatio);
      graphPEGRatio.InnerHtml = g.drawGraphOneAttributeWithFiveFigures(Dictionary.Translate("PEG_ratio"), "XAxis", Abbreviations.getAbbreviations("PEG_ratio"), PEGRatio, year, false, false, true);
    }
}